package com.his.registration.controller;

import com.his.common.Result;
import com.his.registration.service.DepartmentService;
import com.his.registration.service.SettleCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @BelongsProject: workspace-idea
 * @BelongsPackage: com.his.registration.controller
 * @Author: ZhangYing
 * @Date: 2023/7/1 15:30
 * @Description:
 */
@RestController//组合注解，包含ResponseBody可以和前端交互
@CrossOrigin
@RequestMapping("/department")
public class DepartmentController {
    @Autowired
    private DepartmentService departmentService;
    //查询所有结算类型，供前端初始化
    //查询用GetMapping,新增、修改用PostMapping安全些
    @RequestMapping("/getAllDept")
    public Result getAllDept(){
        List<String> result = departmentService.select();
        return Result.success(result);
    }

    //根据结算类型名得到对应id储存挂号信息使用
    @RequestMapping("/getIdByName")
    public Result getIdByName(String deptName){
        int id = departmentService.getIdByName(deptName);
        return Result.success(id);

    }
}
